package top.wenzz.manage.system.manage.web;

import org.springframework.web.bind.annotation.*;
import top.wenzz.commons.vo.RetMsg;
import top.wenzz.manage.system.manage.entity.SysPermission;
import top.wenzz.manage.system.manage.service.SysPermissionService;
import top.wenzz.commons.utils.ExceptionUtils;
import top.wenzz.commons.web.BasicCrudController;

/**
 * Created by 钟廷员 on 2016/12/15.
 */
@RestController
@RequestMapping("sys/permission")
public class SysPermissionController extends BasicCrudController<SysPermission, SysPermissionService> {

    @RequestMapping( value = "getPermissionResources/{id}", method = RequestMethod.POST )
    public Object getPermissionResources(@PathVariable int id) {
        return RetMsg.success(service.getOne(id).getResources());
    }

    @RequestMapping( value = "updateResources", method = RequestMethod.POST )
    public Object updateResources(@RequestBody SysPermission entity) {
        String ret;
        try {
            ret = service.updateResources(entity);
        } catch (Exception e) {
            ret = ExceptionUtils.getExceptionMsg(e);
        }
        return ret(ret, "修改成功");
    }

}
